<script setup lang="ts">
import { onMounted } from 'vue';

import { Page } from '@vben/common-ui';

import { mapData } from '../commonData';
import mapConfig from '../mapConfig';

const options = mapConfig();
const initMap = () => {
  const mapDom = document.querySelector('#map-container');
  if (mapDom) {
    mapData.mapInstance = options.initMap(mapDom);
    mapData.mapInstance.basemap = 1;
    // 创建基站图层
    options.addFeatureLayers(mapData.mapInstance, mapData.baseLayers);
    mapData.mapInstance.on('load', () => {
      console.log('地图加载完成');
    });
    mapData.mapInstance.on('renderError', () => {
      window.location.reload();
    });
  }
};
onMounted(() => {
  initMap();
});
</script>

<template>
  <Page :auto-content-height="true" title="地图初始化">
    <div id="map-container" class="size-full"></div>
  </Page>
</template>

<style lang="scss" scoped></style>
